package com.zzp.controller;


import com.zzp.pojo.TbBrand;
import com.zzp.pojo.TbCategory;
import com.zzp.pojo.TbGood;
import com.zzp.service.BrandService;
import com.zzp.service.CategoryService;
import com.zzp.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class InfoController {
@Autowired
private GoodService goodService;
    @Autowired
    private CategoryService categoryService;

    @Autowired
    private BrandService brandService;




    @RequestMapping("info/{goodId}")
    public String info(@PathVariable String goodId, String brandId,String categoryId, Model model){
        //根据id查询商品详情
        TbGood good = goodService.selectGoodId(goodId);
        model.addAttribute("good",good);

        //根据id查询手机品牌
        TbBrand brand = brandService.selectBandId(brandId);
        model.addAttribute("brand",brand);


        //根据id查询商品名字
        TbCategory category = categoryService.selectCategoryId(categoryId);
        model.addAttribute("category",category);



        return"info";
    }
}
